<template>
      <div class="layout-login">
        <div v-if="$store.state.user.isLogin">
          <Avatar size="small" src="https://i.loli.net/2017/08/21/599a521472424.jpg" />
          <Dropdown @on-click="clickEvent">
            <a href="javascript:void(0)">
              {{$store.state.user.user.name}}
              <Icon type="ios-arrow-down"></Icon>
            </a>
            <DropdownMenu slot="list" >
              <DropdownItem >驴打滚</DropdownItem>
              <DropdownItem>炸酱面</DropdownItem>
              <DropdownItem name="logout">退出登录</DropdownItem>

            </DropdownMenu>
          </Dropdown>

          </div>
        <div v-else>
          <Button shape='circle' to="/auth/login" >登录</Button>
          <Button shape='circle' to="/auth/register" type="info">注册</Button>
        </div>
      </div>
</template>
<script>
  import Cookie from "js-cookie"
  export default {
    methods: {
      clickEvent(name){
        if (name=='logout'){
          Cookie.set('token','')
          this.$store.commit('user/logout')
        }
      }
    }
  }
</script>

<style>
.layout-login{
    width: 450px;
    float: left;
}
</style>

